﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Net;
using System.IO;
using System.Drawing;
using DACU.Player;
using DACU.Player.Enums;
using DACU.Tools;
using DACU.UserControls;
using DACU.UserControls.Player;
using DACU.VkontakteApi;
using DACU.VkontakteApi.Base;
using DACU.VkontakteApi.Collections;
using DACU.VkontakteApi.Enums;
using DACU.VkontakteApi.LongPoll;
using DACU.Windows;
using TagLib;
using Un4seen.Bass;
using MediaPlayer = DACU.Player.MediaPlayer;
using Path = System.IO.Path;
using Utils = DACU.Tools.Utils;

namespace DACU
{
	/// <summary>
	/// Логика взаимодействия для MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		VKApi api = new VKApi();

		public MainWindow()
		{
			InitializeComponent();
		}

		void GetRequest5()
		{
			VKApi.Login();
		}

		//private int stream;
		/*aids: new VKIdsCollectionHelper<int>{94936213}*/
		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			//GetRequest5();
		}

		private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
		{
			//Bass.BASS_StreamFree(stream);
		}

		private void bFriends_Click(object sender, RoutedEventArgs e)
		{
			var friendsList = new FriendsList
			                 	{
			                 		Source =
			                 			VKApi.GetFriends(
										fields:
			                 					VKFields.nickname |
			                 					VKFields.sex |
			                 					VKFields.photo |
			                 					VKFields.has_mobile
			                 				),
			                 		Owner = this
			                 	};
			friendsList.Show();
			friendsList.Closed += ChildWindow_Closed;
		}

		void ChildWindow_Closed(object sender, EventArgs e)
		{
			Focus();
		}

		private void bPlayer_Click(object sender, RoutedEventArgs e)
		{
			var playerWindow = new PlayerWindow {Owner = this};
			playerWindow.Show();
			playerWindow.Closed += ChildWindow_Closed;
		}

		private void bProfile_Click(object sender, RoutedEventArgs e)
		{
			//try
			//{
				userProfile1.Source = VKApi.GetProfiles( fields: VKFields.All);
			//}
			//catch (Exception ex)
			//{
			//    MessageBox.Show(ex + "\n\n" + (ex is VKException ? (ex as VKException).ErrorCode + "\n" + (ex as VKException).Description : ""));
			//}
		}
	}
}
